<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>创建对象的几种方式</title>
  </head>
  <body>
    <script>
      
      // 对象字面量
      //   var car = {
      //     color: "red",
      //     height: 1.8,
      //     suv: true,
      //   };
      //   console.log(car); //{color: 'red', height: 1.8, suv: true}


      
      // 构造函数
      function Factory(color, height, suv) {
        this.color = color;
        this.height = height;
        this.suv = suv;
      }

      var car1 = new Factory("red", 1.8, true);
      var car2 = new Factory("skyblue", 1.3, false);
      console.log(car1); //Factory {color: 'red', height: 1.8, suv: true}
      console.log(car2); //Factory {color: 'skyblue', height: 1.3, suv: false}
    </script>
  </body>
</html>
